# -*- coding: utf-8 -*-
# @Time    : 2022/6/27 15:36
# @Author  : AUGUS
# @Email   : augus@jilin.com
# @File    : modelsMixin.py
# @Software: PyCharm
from django.db import models


class DateTiemModelsMixin(models.Model):
    """创建和修改时间模型拓展类"""
    create_time = models.DateTimeField(auto_now_add=True, verbose_name='创建时间')
    update_time = models.DateTimeField(auto_now=True, verbose_name='更新时间')

    class Meta:
        abstract = True


class IsDeleteModelMixin(models.Model):
    """逻辑删除模型拓展类"""
    is_delete = models.BooleanField(default=False, verbose_name='逻辑删除')

    def delete(self, using=None, keep_parents=False):
        self.is_delete = True
        self.save()

    class Meta:
        abstract = True


class ModelSetMixin(DateTiemModelsMixin, IsDeleteModelMixin):
    class Meta:
        abstract = True
